<?php

namespace app\admin\model\shop;

use think\Model;


class BoardModel extends Model
{

    

    

    // 表名
    protected $name = 'board';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = false;

    // 定义时间戳字段名
    protected $createTime = false;
    protected $updateTime = false;
    protected $deleteTime = false;

    // 追加属性
    protected $append = [
        'status_text'
    ];
    
    public const STATUS_AVAILABLE = 100; //空闲中
    public const STATUS_OCCUPIED = 200; //使用中

    public const STATUS_ARRAY_TEXT = [
        self::STATUS_AVAILABLE => 'Available',
        self::STATUS_OCCUPIED => 'Occupied',
    ];

    
    public function getStatusList()
    {
        return  self::STATUS_ARRAY_TEXT;
    }


    public function getStatusTextAttr($value, $data)
    {
        $value = $value ?: ($data['status'] ?? '');
        $list = $this->getStatusList();
        return $list[$value] ?? '';
    }




}
